<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>07_jQuery-获取文档对象</title>
</head>
<body>

  <ul>
    <li class="li-1">li-1</li>
    <li class="li-2">li-2</li>
    <li class="li-3">li-3</li>
    <li class="li-4">li-4</li>
    <li class="li-5">li-5</li>
  </ul>

  <div>
    <ul>
      <li class="div-li">jQuery-获取文档对象</li>
    </ul>
  </div>
  <script src="../libs/jquery-3.6.0.js"></script>
  <script>
    // 1. 获取文档对象
    // 1.1 获取整个文档对象
    console.log(document);
    console.log($("document"));

    // 1.2 获取整个body对象
    console.log(document.body);
    console.log($("body"));

    // 1.3 获取整个html对象
    console.log(document.documentElement);
    console.log($("html"));

    // 1.4 获取某个元素对象
    console.log(document.querySelector("ul"));
    console.log($("ul"));

    // 2. 获取子元素对象
    // 2.1 获取第一个子元素对象
    console.log(document.querySelector("ul").querySelectorAll("li"));
    console.log($("ul").find("li"));

    // 2.2 获取某个元素对象
    console.log(document.querySelector("ul > .li-1"));
    console.log($("ul .li-1"))

    // 2.3 获取某个元素对象
    console.log(document.querySelector("div > ul > .div-li"));
    console.log($("div > ul > .div-li"));

    // 2.4 获取某个元素对象
    console.log($('ul li'))
    console.log($('ul li', document.querySelector('div')))


  </script>
  
</body>
</html>